Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Badger: v1 to v3 upgrade #3096

Merged
merged 10 commits into from
Jun 21, 2021
Merged

Conversation

Ashmita152
Copy link
Contributor

Signed-off-by: Ashmita Bohara [email protected]

Which problem is this PR solving?

Relates to #2459 #2987

Short description of the changes

Benchmarks

Badger is well known for high memory usage. We are using very version of badger which makes it almost unusable. I did some benchmark between badger-v1 and badger-v3 using all-in-one image and tracegen.

Badger v1 benchmarks

Started all-in-one with badger-v1 backend from master:

❯ SPAN_STORAGE_TYPE=badger ~/all-in-one-badger-v1 --badger.ephemeral=false --badger.directory-value=/tmp/badger/v1/data --badger.directory-key=/tmp/badger/v1/key  --badger.span-store-ttl=1m --badger.consistency --badger.maintenance-interval=1m

Started tracegen:

❯ go run ./cmd/tracegen -pause 50us -duration 1m

Result:

From htop:

CPU: 107%
Residential Memory: 3840MB
❯ du -sh /tmp/badger/v1
741M    /tmp/badger/v1

Badger v3 benchmarks

Started all-in-one with badger-v3 backend from PR branch:

❯ SPAN_STORAGE_TYPE=badger ~/all-in-one-badger-v3 --badger.ephemeral=false --badger.directory-value=/tmp/badger/v3/data --badger.directory-key=/tmp/badger/v3/key  --badger.span-store-ttl=1m --badger.consistency --badger.maintenance-interval=1m

Started tracegen:

❯ go run ./cmd/tracegen -pause 50us -duration 1m

Result:

From htop:

CPU: 6%
Residential Memory: 677MB
❯ du -sh /tmp/badger/v3
48M    /tmp/badger/v3

I see good performance gain in terms of all three resources: cpu, memory and disk.

Although this is a breaking change but I think we should move in this direction. We know badger makes breaking changes in every major version release.

@Ashmita152 Ashmita152 requested a review from a team as a code owner June 17, 2021 09:27
@codecov
Copy link

codecov bot commented Jun 17, 2021

Codecov Report

Merging #3096 (ee86e43) into master (681dd68) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3096      +/-   ##
==========================================
- Coverage   95.91%   95.91%   -0.01%     
==========================================
  Files         236      236              
  Lines       10252    10251       -1     
==========================================
- Hits         9833     9832       -1     
- Misses        348      349       +1     
+ Partials       71       70       -1     
Impacted Files Coverage Δ
plugin/metrics/prometheus/factory.go 100.00% <ø> (ø)
plugin/sampling/strategystore/adaptive/factory.go 100.00% <ø> (ø)
plugin/sampling/strategystore/static/factory.go 100.00% <ø> (ø)
plugin/storage/badger/spanstore/cache.go 100.00% <ø> (ø)
plugin/storage/badger/spanstore/reader.go 95.37% <ø> (ø)
plugin/storage/badger/spanstore/writer.go 97.01% <ø> (ø)
plugin/storage/cassandra/factory.go 100.00% <ø> (ø)
plugin/storage/es/factory.go 97.75% <ø> (ø)
plugin/storage/grpc/factory.go 100.00% <ø> (ø)
plugin/storage/kafka/factory.go 100.00% <ø> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 681dd68...ee86e43. Read the comment docs.

@albertteoh
Copy link
Contributor

If we want to avoid a breaking change, we could deprecate support for badger v1 (no longer maintain it, along with clear warning logs) and create another span storage type badger_v3. Then eventually decommission badger v1 after a few releases.

@pavolloffay
Copy link
Member

How do people migrate data from version to version in badger? Is there any way to migrate? Would it require writing a custom tool?

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I don't think we should keep v1 around.

Please edit the change log and describe the breaking changes, such as renaming of metrics.

plugin/storage/badger/options.go Show resolved Hide resolved
@Ashmita152
Copy link
Contributor Author

Ashmita152 commented Jun 17, 2021

Thank you everyone for the review. I will work on fixing the build failures and other feedbacks.

How do people migrate data from version to version in badger? Is there any way to migrate? Would it require writing a custom tool?

Reading through the badger github issues, it seems like they suggest to do backup and restore which seems compatible across different versions.

Signed-off-by: Ashmita Bohara <[email protected]>
Signed-off-by: Ashmita Bohara <[email protected]>
@Ashmita152
Copy link
Contributor Author

This PR is ready for review again. Thank you.

Signed-off-by: Ashmita Bohara <[email protected]>
Signed-off-by: Ashmita Bohara <[email protected]>
Signed-off-by: Ashmita Bohara <[email protected]>
Signed-off-by: Ashmita Bohara <[email protected]>
Signed-off-by: Ashmita Bohara <[email protected]>
@Ashmita152
Copy link
Contributor Author

This PR is ready for review again.

Copy link
Contributor

@albertteoh albertteoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple of nits, otherwise LGTM.

plugin/storage/badger/options.go Outdated Show resolved Hide resolved
plugin/storage/badger/options.go Outdated Show resolved Hide resolved
Signed-off-by: Ashmita Bohara <[email protected]>
@@ -136,7 +140,7 @@ func addFlags(flagSet *flag.FlagSet, nsConfig NamespaceConfig) {
flagSet.Bool(
nsConfig.namespace+suffixTruncate,
nsConfig.Truncate,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this field be removed from config struct ?

Signed-off-by: Ashmita Bohara <[email protected]>
@yurishkuro yurishkuro enabled auto-merge (squash) June 21, 2021 14:52
@yurishkuro yurishkuro merged commit f23484b into jaegertracing:master Jun 21, 2021
@Ashmita152 Ashmita152 deleted the badger-v3 branch June 21, 2021 15:00
@jpkrohling jpkrohling added this to the Release 1.24.0 milestone Jun 22, 2021
@jpkrohling
Copy link
Contributor

Reading through the badger github issues, it seems like they suggest to do backup and restore which seems compatible across different versions.

Could you add a link to this in the changelog? So that people know where the migration instructions are located.

@Ashmita152
Copy link
Contributor Author

Ashmita152 commented Jun 24, 2021

I tried the steps and thought to include as part of documentation: jaegertracing/documentation#507

@pavolloffay pavolloffay mentioned this pull request Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants